package com.usian.admin.xxljob;

import com.usian.admin.feign.WmNewsClient;
import com.usian.admin.service.AdWmNewsService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * ClassName: WeMediaNewsAutoScanJob
 * Author:   WGG
 * Date:    2022-11-2022/11/28-9:56
 * Version: 1.0
 * Description:
 */
@Component
public class WeMediaNewsAutoScanJob2 {
    @Value("${server.port}")
    private String appPort;

    @Autowired
    private WmNewsClient wmNewsClient;
    @Autowired
    private AdWmNewsService adWmNewsService;

    /**
     * 状态等于4时定时调度
     * @param param
     * @return
     * @throws Exception
     */
    @XxlJob("weMediaNewsAutoScanJob2")
    public ReturnT<String> hello(String param) throws Exception {
        List<Integer> ids = wmNewsClient.findByStatusIds();
        if (ids.size()>0 && !ids.isEmpty()){
            for (Integer id : ids) {
              adWmNewsService.oneUpdate(id);
            }
        }

        return ReturnT.SUCCESS;
    }
}
